/*
 *  Utility.h
 *  SoundController0002
 *
 *  Created by jiro on 10/07/01.
 *  Copyright 2010 jiro music. All rights reserved.
 *
 */

#pragma once

#include <vector>
#include <boost/random.hpp>

namespace sc 
{

	class Utility
	{
	public:
		template< class T1, class T2 >
		static void CopyByStaticCast( const std::vector< T1 >& source, std::vector< T2 >& destination )
		{
			size_t count = source.size();
			destination.clear();
			destination.resize( count );

			#pragma omp parallel for
			for ( int i = 0; i < count; i++ )
			{
				destination[ i ] = static_cast< T2 >( source[ i ] );
			}
		}
	};
	
	class RandomValueGenerator
	{
	private:

		static boost::minstd_rand* randomValueSeed;

		static boost::uniform_real<>* distribution;

		static boost::variate_generator< boost::minstd_rand&, boost::uniform_real<> >* generator;

	public:
	
		static void Initialize( double seed, double minValue, double maxValue );

		static  double GetValue( double minValue, double maxValue );

	private:

		RandomValueGenerator();

		RandomValueGenerator( double seed, double minValue, double maxValue );

	};

}
